This visualization attempts to find our how Pokemon’s strength changed throughout generations (1-6) and if not-legendary Pokemon can defeat legendary, and what are they?
generations:
I Generation - (1996-1999) New Pokemon - 151
II Generation - (1999-2001) New Pokemon - 100
III Generation - (2002-2005) New Pokemon - 135
IV Generation - (2006-2010) New Pokemon - 107
V Generation - (2010-2013) New Pokemon - 156
VI Generation - (2013-2016) New Pokemon - 72
legendary:
Legendary Pokemon are incredibly rare and often very powerful Pokemon, generally featured prominently in the legends and myths of the Pokemon world.
information source: https://bulbapedia.bulbagarden.net/wiki/Legendary_Pok%C3%A9mon and https://bulbapedia.bulbagarden.net/wiki/Generation .
The data consists of 721 Pokemon and specific for each of them attributes such as HP, Attack, Type.1 etc.
Pokemon data that was used for this project and can be found at: pokemon data
data <- read.csv("data/pokemon_data.csv") #load data
#there are 13 variables which are:
names(data)
## [1] "X." "Name" "Type.1" "Type.2" "Total"
## [6] "HP" "Attack" "Defense" "Sp..Atk" "Sp..Def"
## [11] "Speed" "Generation" "Legendary"
#tidying and removing all except variables we need
df <- data %>% tibble::as_tibble() %>%
distinct(X., .keep_all = TRUE) %>%
select(Name, Type.1, Total, Generation, Legendary) %>%
dplyr::rename(type = Type.1,
name = Name,
total = Total,
generation = Generation,
legendary = Legendary) %>%
arrange(type) %>%
print()
## # A tibble: 721 x 5
## name type total generation legendary
## <chr> <chr> <int> <int> <chr>
## 1 Caterpie Bug 195 1 False
## 2 Metapod Bug 205 1 False
## 3 Butterfree Bug 395 1 False
## 4 Weedle Bug 195 1 False
## 5 Kakuna Bug 205 1 False
## 6 Beedrill Bug 395 1 False
## 7 Paras Bug 285 1 False
## 8 Parasect Bug 405 1 False
## 9 Venonat Bug 305 1 False
## 10 Venomoth Bug 450 1 False
## # ... with 711 more rows
#tidying, changing type
df$legendary[df$legendary=="True"] <- "Legendary"
df$legendary[df$legendary=="False"] <- "Not Legendary"
head(df,10)
## # A tibble: 10 x 5
## name type total generation legendary
## <chr> <chr> <int> <int> <chr>
## 1 Caterpie Bug 195 1 Not Legendary
## 2 Metapod Bug 205 1 Not Legendary
## 3 Butterfree Bug 395 1 Not Legendary
## 4 Weedle Bug 195 1 Not Legendary
## 5 Kakuna Bug 205 1 Not Legendary
## 6 Beedrill Bug 395 1 Not Legendary
## 7 Paras Bug 285 1 Not Legendary
## 8 Parasect Bug 405 1 Not Legendary
## 9 Venonat Bug 305 1 Not Legendary
## 10 Venomoth Bug 450 1 Not Legendary
g1 <- df %>%
mutate(text=paste("Name: ",(df$name), "\nType: ",(df$type), "\nTotal: ", (df$total), sep="")) %>%
ggplot(df,mapping = aes(x = total, y=type, col=type, text=text)) +
geom_point(position = "jitter")+
labs( x="Total strength",
y= NULL,
title="Types of Pokemon")+
theme_minimal()+
theme(axis.text.y=element_blank(),
plot.title = element_text(size=20))+
guides(col=guide_legend("Types of Pokemon"))
p1 <- ggplotly(g1, tooltip="text")
p1
#save output
htmlwidgets::saveWidget(p1, file="graphs/rainbow_pokemon.html")
names(wes_palettes)
## [1] "BottleRocket1" "BottleRocket2" "Rushmore1" "Rushmore"
## [5] "Royal1" "Royal2" "Zissou1" "Darjeeling1"
## [9] "Darjeeling2" "Chevalier1" "FantasticFox1" "Moonrise1"
## [13] "Moonrise2" "Moonrise3" "Cavalcanti1" "GrandBudapest1"
## [17] "GrandBudapest2" "IsleofDogs1" "IsleofDogs2"
g2 <- df %>%
mutate(text=paste("Name: ",(df$name), "\nType: ",(df$type), "\nTotal: ",
(df$total), "\nGen: ", (df$generation), "\n",
(df$legendary),sep="")) %>%
ggplot(df,mapping = aes(x = generation, y=total, col=legendary, text=text)) +
geom_point(position = "jitter")+
labs( x=NULL,
y= "Total strength",
title="Legendary Pokemon")+
theme_minimal()+
theme(axis.text.x=element_blank(),
axis.title.x = element_blank(),
plot.title = element_text(size=20),
panel.grid.major.x = element_blank())+
guides(col=guide_legend("Types of Pokemon"))+
scale_colour_manual(values=wes_palette("Moonrise3"))
p2 <- ggplotly(g2, tooltip="text")
p2
#save output
htmlwidgets::saveWidget(p2, file="graphs/legendary_pokemon.html")
g3 <- df %>%
mutate(text=paste("Name: ",(df$name), "\nType: ",(df$type), "\nTotal: ",
(df$total), "\nGen: ", (df$generation), "\n",
(df$legendary),sep="")) %>%
ggplot(df,mapping = aes(x = generation, y=total, col=type, text=text)) +
geom_point(position = "jitter")+
labs( x=NULL,
y= "Total strength",
title="All Pokemon")+
theme_minimal()+
theme(axis.text.x=element_blank(),
plot.title = element_text(size=20),
panel.grid.major.y = element_line("#e6f2ff"),
panel.grid.major.x = element_blank(),
axis.line = element_line(colour = "#003166"))+
guides(col=guide_legend("Types of Pokemon"))+
scale_color_manual(values = c("Bug"="tan4","Dark"="black","Dragon"="chartreuse4","Electric"="darkgoldenrod1","Fairy"="hotpink","Fighting"="darksalmon","Fire"="firebrick1","Flying"="lightskyblue","Ghost"="darkblue","Grass"="yellowgreen", "Ground"="peru","Ice"="cadetblue1","Normal"="pink","Poison"="maroon","Psychic"="darkviolet","Rock"="wheat3","Steel"="gray","Water"="steelblue1"))
p3 <- ggplotly(g3, tooltip="text")
p3
#save output
htmlwidgets::saveWidget(p3, file="graphs/all_types_interactive.html")
g4 <- ggplot(df,mapping = aes(x = generation, y=total, col=type)) +
geom_point(position = "jitter", size=2)+
labs(title="Now showing {closest_state} Pokemon",
subtitle = 'Frame {frame} of {nframes}',
x=NULL,
y= "Total strength")+
theme_minimal()+
theme(axis.text.x=element_blank(),
axis.title.y = element_text(size=15),
plot.title = element_text(size=20),
panel.grid.major.y = element_line("#e6f2ff"),
axis.line = element_line(colour = "#003166"),
legend.position = "none")+ #removes legend
transition_states(type,
transition_length = 20,
state_length = 10,
wrap = FALSE)+
enter_fade()+
exit_fade()+
scale_color_manual(values = c("Bug"="tan4","Dark"="black","Dragon"="chartreuse4","Electric"="darkgoldenrod1","Fairy"="hotpink","Fighting"="darksalmon","Fire"="firebrick1","Flying"="lightskyblue","Ghost"="darkblue","Grass"="yellowgreen", "Ground"="peru","Ice"="cadetblue1","Normal"="pink","Poison"="maroon","Psychic"="darkviolet","Rock"="wheat3","Steel"="gray","Water"="steelblue1"))
animate(g4 + ease_aes(), width=600,height=600)
#save output
anim_save(file="graphs/all_types_animated.gif")
Caveat #1: Type.2 of Popkemon were not look at, which might be interesting to do so in the future.
Caveat #2: 2 new generations (VII[2016-2019] and VIII [2019-2022]) were not included in the data and there are 177 new Pokemon.
Caveat #3: Comparison of each attributes of Total Score such as HP and Attack might be worth looking at